#!/bin/bash


function get_list() {
file_list=`find . -name "*.$1" -exec grep -l $2 {} \;`
}

#substitue the content from $2 to $3 on the $1 list
function substitute() {
echo "vi -e -s $1 - cmd (:%s/$2/$3/g)"
vi -e -s $1 << EOF
:%s/$2/$3/g
:wq
EOF
}

extension=py
old_passwd=bit!#3dnjf
new_passwd=dlcjs13!#bit
get_list $extension $old_passwd
for file in $file_list
do
	echo $file
	substitute  $file $old_passwd $new_passwd
done
